﻿namespace EggOfPanKu.Library.Objects
{
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Text;
    using System.Xml;
    using System.Xml.Linq;

    using EggOfPanKu.Library.Infrastructure;
    using EggOfPanKu.Library.Objects;

    public class Stronghold : Card
    {
        #region Fields

        private string _Clan;
        private int _Gold;
        private int _StartingHonor;
        private int _Strength;

        #endregion Fields

        #region Constructors

        public Stronghold(string CardID)
            : base(CardID)
        {

        }

        public Stronghold(XElement CardNode)
            : base(CardNode)
        {
            //Set Clan
            string clanName = (string)CardNode.Element("clan");
            if (String.IsNullOrEmpty(clanName))
            {
                ParseWarning("Clan");
                clanName = "Unaligned";
            }
            Clan = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(clanName);
            //Set Gold
            Gold = CardManager.ConvertCardValueToInt(CardNode.Element("gold_production").Value);
            if (String.IsNullOrEmpty(CardNode.Element("gold_production").Value))
                ParseWarning("Gold");

            //Set StartingHonor
            StartingHonor = CardManager.ConvertCardValueToInt(CardNode.Element("starting_honor").Value);
            if (String.IsNullOrEmpty(CardNode.Element("starting_honor").Value))
                ParseWarning("Starting Honor");

            //Set Strength
            Strength = CardManager.ConvertCardValueToInt(CardNode.Element("province_strength").Value);
            if (String.IsNullOrEmpty(CardNode.Element("province_strength").Value))
                ParseWarning("Province Strength");
        }

        #endregion Constructors

        #region Properties

        public override CardType CardType
        {
            get { return CardType.Stronghold; }
        }

        public string Clan
        {
            get { return _Clan; }
            set { _Clan = value; }
        }

        public override CardDeck DeckType
        {
            get { return CardDeck.Stronghold; }
        }

        public int Gold
        {
            get { return _Gold; }
            set { _Gold = value; }
        }

        public int StartingHonor
        {
            get { return _StartingHonor; }
            set { _StartingHonor = value; }
        }

        public int Strength
        {
            get { return _Strength; }
            set { _Strength = value; }
        }

        #endregion Properties
    }
}